﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Firefox;

namespace NPMonitor.Utility
{
    public class WebDriverFactory
    {
        readonly static FirefoxProfile defaultProfile = (new FirefoxProfileManager()).GetProfile("default");

        public static FirefoxProfile FirefoxProfile
        {
            get { return defaultProfile; }
        }

        public static IWebDriver GetWebDriver(string browserType)
        {
            IWebDriver webDriver;

            switch (browserType)
            {
                case BrowserType.IE:
                    var options = new InternetExplorerOptions();
                    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                    webDriver = new InternetExplorerDriver(options);
                    break;
                case BrowserType.FF:
                    FirefoxProfile defaultProfile = (new FirefoxProfileManager()).GetProfile("default");
                    webDriver = new FirefoxDriver(defaultProfile);
                    break;
                default:
                    webDriver = new InternetExplorerDriver();
                    break;
            }

            return webDriver;
        }
    }
}
